<!-- ************************************************************************************************************ -->
<!-- fileName          : client_postsright_display.jsp 															  -->
<!-- summary           : client端  文章列表(左)  页面	显示 																  -->
<!-- ************************************************************************************************************ -->

<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ page import="java.sql.*" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="/immigration/css/guide.css" />
<link rel="stylesheet" type="text/css" href="/immigration/css/bootstrap/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="/immigration/css/bootstrap/bootstrap-responsive.min.css" />
<link rel="stylesheet" type="text/css" href="/immigration/css/layout.css">
<script type="text/javascript" src="/immigration/js/jquery.js"></script>
<script type="text/javascript" src="/immigration/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/immigration/js/guide.js"></script>
<title>Immigration Explore | 探索移民</title>
<style type="text/css">
.main-connent,.right {
	margin-top: 60px;
}

.content {
	padding: 5px 50px;
	overflow: auto;
}

.main-connent {
	width: 75%;
	float: left;
	font-size: 13px;
	line-height: 14px;
	border-radius: 4px;
	box-shadow: 0 0 10px #ccc;
}

.right {
	width: 23%;
	float: right;
	font-size: 13px;
	line-height: 13px;
	border-radius: 4px;
	box-shadow: 0 0 10px #ccc;
}

.main-connent .main-left {
	width: 76%;
	float: left;
}

.main-connent .main-mid {
	width: 23%;
	float: right;
}

.main-connent .main-left .main-left-top {
	width: 100%;
}

.main-connent .main-left .main-left-bottom {
	width: 100%;
}

.main-left-bottom.main-bottom-left {
	width: 30%;
	float: left;
}

.main-left-bottom.main-bottom-right {
	width: 30%;
	float: right;
}

.main-connent .main-mid  .main-mid-top {
	width: 100%
}

.main-connent .main-mid  .main-mid-bottom {
	width: 100%
}

.title-icon {
	padding: 5px 15px;
	border-bottom: #fff 1px solid;
	color: #000000;
	font-weight: bold;
	font-size: 14px;
}

p {
	display: block;
	-webkit-margin-before: 0px;
	-webkit-margin-after: 0px;
	-webkit-margin-start: 0px;
	-webkit-margin-end: 0px;
	padding: 0 20px;
	margin:0;
}

</style>
</head>

<body>

	<div>
	<jsp:include page="/page/client/client_top.jsp"></jsp:include>
	</div>

	<div id="main_content">
<%
	//设置请求的字符编码以支持中文
	request.setCharacterEncoding ("utf-8");
	
	int intPageSize; //一页显示的记录数 
	int intRowCount; //记录总数 
	int intPageCount; //总页数 
	int intPage; //待显示页码 
	String strPage; 
	
	//设置一页显示的记录数 
	intPageSize = 15; 
	
	//取得待显示页码 
	strPage = request.getParameter("page"); 
	if(strPage==null){//表明在QueryString中没有page这一个参数，此时显示第一页数据 
		intPage = 1; 
	}
	else{//将字符串转换成整型 
		intPage = java.lang.Integer.parseInt(strPage); 
		if(intPage< 1){ 
			intPage = 1; 
		} 
	} 
	//获取请求参数
	String currentId = request.getParameter("CId");
	
	//从web.xml获取全局参数
	String drv=config.getServletContext().getInitParameter("DBDriver");
	String url=config.getServletContext().getInitParameter("DBURL");
	String uid=config.getServletContext().getInitParameter("DBUser");
	String pwd=config.getServletContext().getInitParameter("DBPass");
	
	//构建SQL字符串和JDBC对象
	String strSQL1 = "SELECT * FROM immie0_immi.postsright p WHERE p.id=?";	// id name content_name content date
	String strSQL2 = "SELECT * FROM immie0_immi.postsright order by date desc ";		//id name content_name content date
	String strSQL3 = "SELECT * FROM immie0_immi.contentlink cl WHERE cl.father_id=-1";	// (id, name, content_name, content, url, father_id, date)
	
	Connection conn = null;
	PreparedStatement pstmt1 = null;	
	PreparedStatement pstmt2 = null;
	PreparedStatement pstmt3 = null;
	ResultSet rs1 = null; //要显示的页面id
	ResultSet rs2 = null; //文章列表（左）
	ResultSet rs3 = null; //文章标题处常用链接
%>		
  		
  		<div id="sidebar" style="margin-right:5px;">
			<div class="pnav-cnt">
				<div class="pnav-box">
					<div class="box-title-left">
						<span class="pnav-letter"><a href="/immigration/page/client/client_postsright_list.jsp">文章列表</a></span>
					</div>
<% 
		try {
			Class.forName(drv).newInstance();
			conn = DriverManager.getConnection(url,uid,pwd);
			pstmt1 = conn.prepareStatement(strSQL1);		
			//设置SQL语句的参数
			pstmt1.setString(1, currentId);	
			rs1 = pstmt1.executeQuery();
			rs1.next();

			pstmt2 = conn.prepareStatement(strSQL2);		
						
			rs2 = pstmt2.executeQuery();
			rs2.absolute(1); 
						
			//获取记录总数 
			rs2.last(); 
			intRowCount = rs2.getRow(); 

			//记算总页数 
			intPageCount = (intRowCount+intPageSize-1) / intPageSize; 

			//调整待显示的页码 
			if(intPage >intPageCount) intPage = intPageCount; 
					
			if(intPageCount >0){ 
				//将记录指针定位到待显示页的第一条记录上 
				rs2.absolute((intPage-1) * intPageSize+1); 
				//显示数据 
				int i = 0; 				%>
					<ul class="nav nav-pills nav-stacked">
<%
				while(i< intPageSize && !rs2.isAfterLast()){ 	
%>						<li><a style="word-break:keep-all;/* 不换行 */white-space:nowrap;/* 不换行 */overflow:hidden;/* 内容超出宽度时隐藏超出部分的内容 */text-overflow:ellipsis;/* 当对象内文本溢出时显示省略标记(...) ；需与overflow:hidden;一起使用。*/" href="/immigration/page/client/client_postsright_display.jsp?CId=<%=rs2.getString(1)%>&page=<%=intPage%>"  ><%=rs2.getString(2)%></a></li>
<%					rs2.next(); 
					i++; 
				}rs2.close(); 
				i=0; 

				if(intPage<2){ %> 
						<li><a style="float:left;" >上一页</a>
<%				}else{	%> 
						<li><a style="float:left;" href="/immigration/page/client/client_postsright_display.jsp?page=<%=intPage-1%>&CId=<%=rs1.getString(1)%>">上一页</a> 
<%				}
				if((intPageCount-intPage)<1) {	%> 
							<a style="float:right;">下一页</a> </li>
<%				}else{%> 
							<a style="float:right;" href="/immigration/page/client/client_postsright_display.jsp?page=<%=intPage+1%>&CId=<%=rs1.getString(1)%>">下一页</a> </li>
<%				} 
			} 
			else{ 
				out.print("<center><table border=0 align=center cellpadding=0 cellspacing=1 ><tr><td><center>目前还没有内容！</center></td></tr></table></centre>"); 
			} 	
%>					</ul>
				</div>
			</div>
		</div>
		
		<div id="postsrightcontent" style=" min-height:748px; border-left:#dcdddd 1px solid; border-top:#dcdddd 1px solid; border-right:#dcdddd 1px solid; margin:0 0 0 187px !important; background-image: url(/immigration/image/client_bg.png);" >
				
			<div id="content-title">
		 		<font><%=rs1.getString(3) %></font>
		 	</div>
			 	
		 	<div  id="content-timeline">
		 		<font style="font-family: Microsoft YaHei;	font-size:15px; float:left;">修改时间：<%=rs1.getDate(5) %></font>
		 		<div style="float:left;">
	 				<font style="font-family: Microsoft YaHei;	font-size:15px; margin-left:20px;">常用链接：</font>
<% 				
			pstmt3 = conn.prepareStatement(strSQL3);		
						
			rs3 = pstmt3.executeQuery();			
			while(rs3.next()) {						%>
					<a href="/immigration/page/client/client_contentlink_display.jsp?CId=<%=rs3.getString(1) %>" ><%=rs3.getString(2) %></a>
<%			}		%>
		 		</div>
			 </div>
					
			<div id="content-content"><%=rs1.getString(4) %></div>

		</div>
	
		<br class="clearfloat" /> 
	
	</div>

	<div>
	<jsp:include page="/page/footer.jsp"></jsp:include>
	</div>
	
<%		
	} catch (ClassNotFoundException e) {
		e.printStackTrace();
	} catch (InstantiationException e) {
	    e.printStackTrace();
	} catch (IllegalAccessException e) {
		e.printStackTrace();
	} catch (SQLException e) {
		e.printStackTrace();
	} 
	finally {
		if (rs1 != null) {
			rs1.close();
			rs1 = null;
		}
		if (rs2 != null) {
			rs2.close();
			rs2 = null;
		}
		if (rs3 != null) {
			rs3.close();
			rs3 = null;
		}
		if (pstmt1 != null) {
			pstmt1.close();
			pstmt1 = null;
		}
		if (pstmt2 != null) {
			pstmt2.close();
			pstmt2 = null;
		}
		if (pstmt3 != null) {
			pstmt3.close();
			pstmt3 = null;
		}
		if (conn != null) {
			conn.close();
			conn = null;
		}
	}		%>	

</body>
</html>









